home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / toolpack.000 / toolpack / toolpack1.2 / scriptsource / ucs.s < prev    next >
Encoding:
Text File  |  1993-10-04  |  5.3 KB  |  174 lines

  1. #! /bin/csh
  2. #  ucs is a csh script to unroll, condense, and make eliminations and
  3. #  substitutions in Fortran DO loops using ISTUD, ISTCD, and ISTSB.
  4. #
  5. #
  6. #  Invocation:
  7. #
  8. #  ucs depth Polish_option_file Fortran_source_file
  9. #
  10. #  Check command line validity.
  11. if ( $#argv < 3 ) then
  12. TOOLPACKPATH/toolpack1.2/util/echoerr \
  13. Invocation:
  14. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  15. TOOLPACKPATH/toolpack1.2/util/echoerr \
  16. "ucs depth Polish_option_file Fortran_source_file"
  17. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  18. TOOLPACKPATH/toolpack1.2/util/echoerr \
  19. "depth specifies the unrolling depth (see references in Users' Guide)."
  20. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  21. TOOLPACKPATH/toolpack1.2/util/echoerr \
  22. 'Polish_option_file is created by using script "polx".'
  23. TOOLPACKPATH/toolpack1.2/util/echoerr \
  24. '"-" in place of Polish_option_file gives default formatting options.'
  25. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  26. TOOLPACKPATH/toolpack1.2/util/echoerr \
  27. Transformed code is sent to standard output and may be redirected to a file.
  28. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  29.    exit
  30. endif
  31. #  "-" as Polish_option_file gives default options.
  32. if ( $2 != -) then
  33. #  Check that Polish_option_file exists.
  34.    if ( -e $2 == 0 ) then
  35. TOOLPACKPATH/toolpack1.2/util/echoerr \
  36. "'$2' does not exist."
  37.       exit
  38.    endif
  39. endif
  40. #  Check that Fortran_source_file exists.
  41. if ( -e $3 == 0 ) then
  42. TOOLPACKPATH/toolpack1.2/util/echoerr \
  43. "'$3' does not exist."
  44.    exit
  45. endif
  46. #
  47. #  Create PFS.  If PFS already exists, exit with an advisory message.
  48. #
  49. if ( -e _.TOOLPACK == 0 ) then
  50.    mkdir _.TOOLPACK
  51. else
  52. TOOLPACKPATH/toolpack1.2/util/echoerr \
  53. Toolpack-created directory '"_.TOOLPACK"' exists. \
  54. Remove with script '"discard"'.
  55.    exit
  56. endif
  57. #  Make a tab-free copy of the Fortran source and use it as source.
  58. set src = lx.src$$
  59. expand $3 > _.TOOLPACK/$src
  60. #  Lexer token stream file name.
  61. set tkn = _.lxtkn
  62. #  Lexer comment file name.
  63. set cmt = _.lxcmt
  64. #  Create the interprocess file IST.CMD and append parameters for ISTLX.
  65. TOOLPACKPATH/toolpack1.2/util/mkipf \
  66. $src - $tkn $cmt
  67. #
  68. #  Invoke ISTLX.
  69. #
  70. TOOLPACKPATH/toolpack1.2/exec/istlx.u
  71. #
  72. #  If lexer errors are reported, advise user to obtain listing and exit.
  73. if ( `cat _.TOOLPACK/_.info` == -1 ) then
  74. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  75. TOOLPACKPATH/toolpack1.2/util/echoerr \
  76. 'Program has lexical scanning errors.  Invoke script "getlst"'
  77. TOOLPACKPATH/toolpack1.2/util/echoerr \
  78. to obtain a listing showing statement and token numbers.
  79. TOOLPACKPATH/toolpack1.2/util/echoerr ""
  80.    /bin/rm -r _.TOOLPACK
  81.    exit
  82. endif
  83. #  Output token stream file name.
  84. set tknout = _.tknout
  85. #  Output comment stream file name.
  86. set cmtout = _.cmtout
  87. #  Create the interprocess file IST.CMD and append parameters for ISTUD.
  88. TOOLPACKPATH/toolpack1.2/util/mkipf \
  89. $tkn $cmt $tknout $cmtout $1
  90. #
  91. #  Invoke ISTUD.
  92. #
  93. TOOLPACKPATH/toolpack1.2/exec/istud.u
  94. #
  95. #  Set up the output from ISTUD as input to ISTCD.
  96. mv _.TOOLPACK/$tknout _.TOOLPACK/$tkn
  97. mv _.TOOLPACK/$cmtout _.TOOLPACK/$cmt
  98. #  Create the interprocess file IST.CMD and append parameters for ISTCD.
  99. TOOLPACKPATH/toolpack1.2/util/mkipf \
  100. $tkn $cmt $tknout $cmtout
  101. #
  102. #  Invoke ISTCD.
  103. #
  104. TOOLPACKPATH/toolpack1.2/exec/istcd.u
  105. #
  106. #  The variable 'condense' is initialized to 'no' and will be reset to
  107. #  'yes' if ISTCD is repeated at least once, thereby indicating that
  108. #  some condensation has occurred.
  109. set condense = no
  110. #  If the termination flag is TERMFLAG_0 (= -2000) or TERMFLAG_1 (= -2001)
  111. #  repeat ISTCD, invoking ISTSB first if the flag is TERMFLAG_1.
  112. while ( `cat _.TOOLPACK/_.info` == -2000 || `cat _.TOOLPACK/_.info` == -2001 )
  113.    set condense = yes
  114.    if ( `cat _.TOOLPACK/_.info` == -2001 ) then
  115. #  Set up the output from ISTCD as input to ISTSB.
  116.       mv _.TOOLPACK/$tknout _.TOOLPACK/$tkn
  117.       mv _.TOOLPACK/$cmtout _.TOOLPACK/$cmt
  118. #  Create the interprocess file IST.CMD and append parameters for ISTSB.
  119. TOOLPACKPATH/toolpack1.2/util/mkipf \
  120. $tkn $cmt $tknout $cmtout
  121. #
  122. #  Invoke ISTSB (ISTSB is re-entered internally if substitutions are made).
  123. #
  124. TOOLPACKPATH/toolpack1.2/exec/istsb.u
  125. #
  126.    endif
  127. #  Set up the output from ISTCD or ISTSB as input to ISTCD.
  128.    mv _.TOOLPACK/$tknout _.TOOLPACK/$tkn
  129.    mv _.TOOLPACK/$cmtout _.TOOLPACK/$cmt
  130. #  Create the interprocess file IST.CMD and append parameters for ISTCD.
  131. TOOLPACKPATH/toolpack1.2/util/mkipf \
  132. $tkn $cmt $tknout $cmtout
  133. #
  134. #  Invoke ISTCD.
  135. #
  136. TOOLPACKPATH/toolpack1.2/exec/istcd.u
  137. end
  138. #  Set up the output from ISTCD as input to ISTSB.
  139. mv _.TOOLPACK/$tknout _.TOOLPACK/$tkn
  140. mv _.TOOLPACK/$cmtout _.TOOLPACK/$cmt
  141. #  Set up the interprocess file IST.CMD and append parameters for ISTSB.
  142. TOOLPACKPATH/toolpack1.2/util/mkipf \
  143. $tkn $cmt $tknout $cmtout
  144. #
  145. #  Invoke ISTSB (ISTSB is re-entered internally if substitutions are made).
  146. #
  147. TOOLPACKPATH/toolpack1.2/exec/istsb.u
  148. #
  149. #  If no condensation occurred, output the original source.
  150. if ( $condense == no ) then
  151. TOOLPACKPATH/toolpack1.2/util/echoerr \
  152. No condensation occurred, original source is output.
  153.    cat $3
  154. else
  155. #  Otherwise, Polish and output the transformed Fortran.
  156.    if ( $2 == - ) then
  157. TOOLPACKPATH/toolpack1.2/util/mkipf \
  158. $tknout $cmtout \#1 -
  159.    else
  160. TOOLPACKPATH/toolpack1.2/util/mkipf \
  161. $tknout $cmtout \#1 \#$2
  162.    endif
  163. #
  164. #  Invoke ISTPL.
  165. #
  166. TOOLPACKPATH/toolpack1.2/exec/istpl.u
  167. endif
  168. #
  169. #  Move temporary files (comment indices for generated label control)
  170. #  to the PFS where they will be removed.
  171. mv udcmitmp cdcmitmp _.TOOLPACK
  172. /bin/rm -r _.TOOLPACK
  173. #
  174.